package com.yue.jmx.demo2;

import javax.management.*;
import java.lang.management.ManagementFactory;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2017/1/3<br/>
 *
 * @author QiuYang
 */
public class MessageEngineAgent {
    public void start(){
        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();

        try {
            ObjectName mxbeanName = new ObjectName("com.yue.jmx.demo2:type=MessageEngin");
            MessageEngineMXBean mxBean = new MessageEngine();
            mBeanServer.registerMBean(mxBean, mxbeanName);
        } catch (MalformedObjectNameException e) {
            e.printStackTrace();
        } catch (NotCompliantMBeanException e) {
            e.printStackTrace();
        } catch (InstanceAlreadyExistsException e) {
            e.printStackTrace();
        } catch (MBeanRegistrationException e) {
            e.printStackTrace();
        }
    }
}
